export default {
	// 为当前模块开启命名空间
	namespaced: true,

	// 模块的 state 数据
	state: {
		footmark: JSON.parse(uni.getStorageSync('footmark') || '[]'),

	},

	// 模块的 mutations 方法
	mutations: {
		addFootmark(state, footmark) {
			let findFmk = state.footmark.some(item => item.goods_id == footmark.goods_id) //是否重复
			if (!findFmk) {
				state.footmark.push(footmark)
			}

			this.commit('footmark/saveFootmarkToStorage')
		},
		deleteFootmark(state, footmarkId){
			  state.footmark = state.footmark.filter(item => item.goods_id !== footmarkId)
				console.log(state.footmark)
				this.commit("footmark/saveFootmarkToStorage")
		},
		saveFootmarkToStorage(state) {
			uni.setStorageSync('footmark', JSON.stringify(state.footmark))
		},
		deleteFootmarkToStorage(state) {
			uni.removeStorageSync('footmark');
			state.footmark = []
		},
	},

	// 模块的 getters 属性
	getters: {
		getFootmarkLenght(state) {
			return state.footmark.length
		}
	},
}